package com.zxq.frame.rabbitmq.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.rabbit.connection.ConnectionFactory;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class DirectExchangeConfig {

	@Value("${spring.rabbitmq.template.exchange}")
	String exchange;

	@Value("${spring.rabbitmq.template.tcp-channel-queue}")
	String network_channel_queue;
	@Value("${spring.rabbitmq.template.tcp-channel-route-key}")
	String network_channel_route_key;



	@Value("${spring.rabbitmq.template.http-channel-queue}")
	String web_channel_queue;
	@Value("${spring.rabbitmq.template.http-channel-route-key}")
	String web_channel_route_key;



	@Bean
 	public DirectExchange directExchange(){
		DirectExchange directExchange = new DirectExchange(exchange);
 		return directExchange;
 	}
	


	@Bean
	public Queue directWebChannelQueue() {
		Queue queue = new Queue(web_channel_queue);
		return queue;
	}
 	

	@Bean
	public Queue directNetworkChannelQueue() {
		Queue queue = new Queue(network_channel_queue);
		return queue;
	}


	@Bean
	public Binding bindingWebChannel(){
		Binding binding = BindingBuilder.bind(directWebChannelQueue()).to(directExchange()).with( web_channel_route_key);
		return binding;
	}
 	


	@Bean
	public Binding bindingNetworkChannel(){
		Binding binding = BindingBuilder.bind(directNetworkChannelQueue()).to(directExchange()).with( network_channel_route_key);
		return binding;
	}

 	
 	
 	
}
